home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmts.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  31.5 KB  |  1,122 lines

  1. #ifndef H_RPMTS
  2. #define H_RPMTS
  3.  
  4. /** \ingroup rpmts
  5.  * \file lib/rpmts.h
  6.  * Structures and prototypes used for an "rpmts" transaction set.
  7.  */
  8.  
  9. #include "rpmps.h"
  10. #include "rpmsw.h"
  11. #include "rpmsx.h"
  12.  
  13. /*@-exportlocal@*/
  14. /*@unchecked@*/
  15. extern int _rpmts_debug;
  16. /*@unchecked@*/
  17. extern int _rpmts_stats;
  18. /*@unchecked@*/
  19. extern int _fps_debug;
  20. /*@=exportlocal@*/
  21.  
  22. /**
  23.  * Bit(s) to control digest and signature verification.
  24.  */
  25. typedef enum rpmVSFlags_e {
  26.     RPMVSF_DEFAULT    = 0,
  27.     RPMVSF_NOHDRCHK    = (1 <<  0),
  28.     RPMVSF_NEEDPAYLOAD    = (1 <<  1),
  29.     /* bit(s) 2-7 unused */
  30.     RPMVSF_NOSHA1HEADER    = (1 <<  8),
  31.     RPMVSF_NOMD5HEADER    = (1 <<  9),    /* unimplemented */
  32.     RPMVSF_NODSAHEADER    = (1 << 10),
  33.     RPMVSF_NORSAHEADER    = (1 << 11),    /* unimplemented */
  34.     /* bit(s) 12-15 unused */
  35.     RPMVSF_NOSHA1    = (1 << 16),    /* unimplemented */
  36.     RPMVSF_NOMD5    = (1 << 17),
  37.     RPMVSF_NODSA    = (1 << 18),
  38.     RPMVSF_NORSA    = (1 << 19)
  39.     /* bit(s) 16-31 unused */
  40. } rpmVSFlags;
  41.  
  42. /**
  43.  * Transaction Types
  44.  */
  45. typedef enum rpmtsType_e {
  46.     RPMTRANS_TYPE_NORMAL       = 0,
  47.     RPMTRANS_TYPE_ROLLBACK     = (1 << 0),
  48.     RPMTRANS_TYPE_AUTOROLLBACK = (1 << 1)
  49. } rpmtsType;
  50.  
  51. #define    _RPMVSF_NODIGESTS    \
  52.   ( RPMVSF_NOSHA1HEADER |    \
  53.     RPMVSF_NOMD5HEADER |    \
  54.     RPMVSF_NOSHA1 |        \
  55.     RPMVSF_NOMD5 )
  56.  
  57. #define    _RPMVSF_NOSIGNATURES    \
  58.   ( RPMVSF_NODSAHEADER |    \
  59.     RPMVSF_NORSAHEADER |    \
  60.     RPMVSF_NODSA |        \
  61.     RPMVSF_NORSA )
  62.  
  63. #define    _RPMVSF_NOHEADER    \
  64.   ( RPMVSF_NOSHA1HEADER |    \
  65.     RPMVSF_NOMD5HEADER |    \
  66.     RPMVSF_NODSAHEADER |    \
  67.     RPMVSF_NORSAHEADER )
  68.  
  69. #define    _RPMVSF_NOPAYLOAD    \
  70.   ( RPMVSF_NOSHA1 |        \
  71.     RPMVSF_NOMD5 |        \
  72.     RPMVSF_NODSA |        \
  73.     RPMVSF_NORSA )
  74.  
  75. /**
  76.  * Indices for timestamps.
  77.  */
  78. typedef    enum rpmtsOpX_e {
  79.     RPMTS_OP_TOTAL        =  0,
  80.     RPMTS_OP_CHECK        =  1,
  81.     RPMTS_OP_ORDER        =  2,
  82.     RPMTS_OP_FINGERPRINT    =  3,
  83.     RPMTS_OP_REPACKAGE        =  4,
  84.     RPMTS_OP_INSTALL        =  5,
  85.     RPMTS_OP_ERASE        =  6,
  86.     RPMTS_OP_SCRIPTLETS        =  7,
  87.     RPMTS_OP_COMPRESS        =  8,
  88.     RPMTS_OP_UNCOMPRESS        =  9,
  89.     RPMTS_OP_DIGEST        = 10,
  90.     RPMTS_OP_SIGNATURE        = 11,
  91.     RPMTS_OP_DBADD        = 12,
  92.     RPMTS_OP_DBREMOVE        = 13,
  93.     RPMTS_OP_DBGET        = 14,
  94.     RPMTS_OP_DBPUT        = 15,
  95.     RPMTS_OP_DBDEL        = 16,
  96.     RPMTS_OP_MAX        = 17
  97. } rpmtsOpX;
  98.  
  99. #if defined(_RPMTS_INTERNAL)
  100.  
  101. #include "rpmhash.h"    /* XXX hashTable */
  102. #include "rpmal.h"    /* XXX availablePackage/relocateFileList ,*/
  103.  
  104. /**********************
  105.  * Transaction Scores *
  106.  **********************
  107.  *
  108.  * In order to allow instance counts to be adjusted properly when an
  109.  * autorollback transaction is ran, we keep a list that is indexed
  110.  * by rpm name of whether the rpm has been installed or erased.  This listed
  111.  * is only updated:
  112.  *
  113.  *    iif autorollbacks are enabled.
  114.  *    iif this is not a rollback or autorollback transaction.
  115.  *
  116.  * When creating an autorollback transaction, its rpmts points to the same
  117.  * rpmtsScore object as the running transaction.  So when the autorollback
  118.  * transaction runs it can see where each package was in the running transaction
  119.  * at the point the running transaction failed, and thus on a per package
  120.  * basis make adjustments to the instance counts.
  121.  *
  122.  * XXX: Jeff, I am not convinced that this does not need to be in its own file
  123.  *      (i.e. rpmtsScore.{h,c}), but I first wanted to get it working.
  124.  */
  125. struct rpmtsScoreEntry_s {
  126.     char *         N;            /*!<Name of package                */
  127.     rpmElementType te_types;        /*!<te types this entry represents */
  128.     int            installed;        /*!<Was the new header installed   */
  129.     int            erased;        /*!<Was the old header removed     */
  130. };
  131.  
  132. typedef /*@abstract@*/ struct rpmtsScoreEntry_s * rpmtsScoreEntry;
  133.  
  134. struct rpmtsScore_s {
  135.     int entries;            /*!< Number of scores       */
  136.     rpmtsScoreEntry * scores;    /*!< Array of score entries */
  137.         int nrefs;            /*!< Reference count.       */
  138. };
  139.  
  140. typedef /*@abstract@*/ struct rpmtsScore_s * rpmtsScore;
  141.  
  142.  
  143. /** \ingroup rpmts
  144.  * initialize rpmtsScore for running transaction and autorollback
  145.  * transaction.
  146.  * @param runningTS    Running Transaction.
  147.  * @param rollbackTS    Rollback Transaction.
  148.  * @return        RPMRC_OK
  149.  */
  150. rpmRC rpmtsScoreInit(rpmts runningTS, rpmts rollbackTS)
  151.     /*@globals fileSystem @*/
  152.     /*@modifies runningTS, rollbackTS, fileSystem @*/;
  153.  
  154. /** \ingroup rpmts
  155.  * Free rpmtsScore provided no more references exist against it.
  156.  * @param score        rpmtsScore to free
  157.  * @return        NULL always
  158.  */
  159. /*@-exportlocal@*/
  160. /*@null@*/
  161. rpmtsScore rpmtsScoreFree(/*@only@*/ /*@null@*/ rpmtsScore score)
  162.     /*@modifies score @*/;
  163. /*@=exportlocal@*/
  164.  
  165. /** \ingroup rpmts
  166.  * Get rpmtsScore from transaction.
  167.  * @param ts    RPM Transaction.
  168.  * @return    rpmtsScore or NULL.
  169.  */
  170. /*@exposed@*/ /*@null@*/
  171. rpmtsScore rpmtsGetScore(rpmts ts)
  172.     /*@*/;
  173.  
  174. /** \ingroup rpmts
  175.  * Get rpmtsScoreEntry from rpmtsScore.
  176.  * @param score   RPM Transaction Score.
  177.  * @return      rpmtsScoreEntry or NULL.
  178.  */
  179. /*@null@*/
  180. rpmtsScoreEntry rpmtsScoreGetEntry(rpmtsScore score, const char *N)
  181.     /*@*/;
  182.  
  183. /** \ingroup rpmts
  184.  * \file lib/rpmts.h
  185.  * Structures and prototypes used for an "rpmts" transaction set.
  186.  */
  187.  
  188. /**************************
  189.  * END Transaction Scores *
  190.  **************************/
  191.  
  192. /*@unchecked@*/
  193. /*@-exportlocal@*/
  194. extern int _cacheDependsRC;
  195. /*@=exportlocal@*/
  196.  
  197. /** \ingroup rpmts
  198.  */
  199. typedef    /*@abstract@*/ struct diskspaceInfo_s * rpmDiskSpaceInfo;
  200.  
  201. /** \ingroup rpmts
  202.  */
  203. struct diskspaceInfo_s {
  204.     dev_t dev;            /*!< File system device number. */
  205.     signed long bneeded;    /*!< No. of blocks needed. */
  206.     signed long ineeded;    /*!< No. of inodes needed. */
  207.     int bsize;            /*!< File system block size. */
  208.     signed long long bavail;    /*!< No. of blocks available. */
  209.     signed long long iavail;    /*!< No. of inodes available. */
  210. };
  211.  
  212. /** \ingroup rpmts
  213.  * Adjust for root only reserved space. On linux e2fs, this is 5%.
  214.  */
  215. #define    adj_fs_blocks(_nb)    (((_nb) * 21) / 20)
  216.  
  217. /* argon thought a shift optimization here was a waste of time...  he's
  218.    probably right :-( */
  219. #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
  220.  
  221. /** \ingroup rpmts
  222.  */
  223. typedef enum tsStage_e {
  224.     TSM_UNKNOWN        =  0,
  225.     TSM_INSTALL        =  7,
  226.     TSM_ERASE        =  8,
  227. } tsmStage;
  228.  
  229. /** \ingroup rpmts
  230.  * The set of packages to be installed/removed atomically.
  231.  */
  232. struct rpmts_s {
  233.     rpmtransFlags transFlags;    /*!< Bit(s) to control operation. */
  234.     tsmStage goal;        /*!< Transaction goal (i.e. mode) */
  235.     rpmtsType type;             /*!< default, rollback, autorollback */
  236.  
  237. /*@refcounted@*/ /*@null@*/
  238.     rpmdb sdb;            /*!< Solve database handle. */
  239.     int sdbmode;        /*!< Solve database open mode. */
  240. /*@null@*/
  241.     int (*solve) (rpmts ts, rpmds key, const void * data)
  242.     /*@modifies ts @*/;    /*!< Search for NEVRA key. */
  243. /*@relnull@*/
  244.     const void * solveData;    /*!< Solve callback data */
  245.     int nsuggests;        /*!< No. of depCheck suggestions. */
  246. /*@only@*/ /*@null@*/
  247.     const void ** suggests;    /*!< Possible depCheck suggestions. */
  248.  
  249. /*@observer@*/ /*@null@*/
  250.     rpmCallbackFunction notify;    /*!< Callback function. */
  251. /*@observer@*/ /*@null@*/
  252.     rpmCallbackData notifyData;    /*!< Callback private data. */
  253.  
  254. /*@refcounted@*/ /*@null@*/
  255.     rpmps probs;        /*!< Current problems in transaction. */
  256.     rpmprobFilterFlags ignoreSet;
  257.                 /*!< Bits to filter current problems. */
  258.  
  259.     int filesystemCount;    /*!< No. of mounted filesystems. */
  260. /*@dependent@*/ /*@null@*/
  261.     const char ** filesystems;    /*!< Mounted filesystem names. */
  262. /*@only@*/ /*@null@*/
  263.     rpmDiskSpaceInfo dsi;    /*!< Per filesystem disk/inode usage. */
  264.  
  265. /*@refcounted@*/ /*@null@*/
  266.     rpmdb rdb;            /*!< Install database handle. */
  267.     int dbmode;            /*!< Install database open mode. */
  268. /*@only@*/
  269.     hashTable ht;        /*!< Fingerprint hash table. */
  270.  
  271. /*@only@*/ /*@null@*/
  272.     int * removedPackages;    /*!< Set of packages being removed. */
  273.     int numRemovedPackages;    /*!< No. removed package instances. */
  274.     int allocedRemovedPackages;    /*!< Size of removed packages array. */
  275.  
  276. /*@only@*/
  277.     rpmal addedPackages;    /*!< Set of packages being installed. */
  278.     int numAddedPackages;    /*!< No. added package instances. */
  279.  
  280. #ifndef    DYING
  281. /*@only@*/
  282.     rpmal availablePackages;    /*!< Universe of available packages. */
  283.     int numAvailablePackages;    /*!< No. available package instances. */
  284. #endif
  285.  
  286. /*@refcounted@*/ /*@null@*/
  287.     rpmsx sx;            /*!< Security context patterns. */
  288.  
  289. /*@null@*/
  290.     rpmte relocateElement;    /*!< Element to use when relocating packages. */
  291.  
  292. /*@owned@*/ /*@relnull@*/
  293.     rpmte * order;        /*!< Packages sorted by dependencies. */
  294.     int orderCount;        /*!< No. of transaction elements. */
  295.     int orderAlloced;        /*!< No. of allocated transaction elements. */
  296.     int unorderedSuccessors;    /*!< Index of 1st element of successors. */
  297.     int ntrees;            /*!< No. of dependency trees. */
  298.     int maxDepth;        /*!< Maximum depth of dependency tree(s). */
  299.  
  300.     int selinuxEnabled;        /*!< Is SE linux enabled? */
  301.     int chrootDone;        /*!< Has chroot(2) been been done? */
  302. /*@only@*/ /*@null@*/
  303.     const char * rootDir;    /*!< Path to top of install tree. */
  304. /*@only@*/ /*@null@*/
  305.     const char * currDir;    /*!< Current working directory. */
  306. /*@null@*/
  307.     FD_t scriptFd;        /*!< Scriptlet stdout/stderr. */
  308.     int delta;            /*!< Delta for reallocation. */
  309.     int_32 tid;            /*!< Transaction id. */
  310.  
  311.     uint_32 color;        /*!< Transaction color bits. */
  312.     uint_32 prefcolor;        /*!< Preferred file color. */
  313.  
  314.     rpmVSFlags vsflags;        /*!< Signature/digest verification flags. */
  315.  
  316. /*@observer@*/ /*@dependent@*/ /*@null@*/
  317.     const char * fn;        /*!< Current package fn. */
  318.     int_32  sigtag;        /*!< Current package signature tag. */
  319.     int_32  sigtype;        /*!< Current package signature data type. */
  320. /*@null@*/
  321.     const void * sig;        /*!< Current package signature. */
  322.     int_32 siglen;        /*!< Current package signature length. */
  323.  
  324. /*@only@*/ /*@null@*/
  325.     const unsigned char * pkpkt;/*!< Current pubkey packet. */
  326.     size_t pkpktlen;        /*!< Current pubkey packet length. */
  327.     unsigned char pksignid[8];    /*!< Current pubkey fingerprint. */
  328.  
  329.     struct rpmop_s ops[RPMTS_OP_MAX];
  330.  
  331. /*@null@*/
  332.     pgpDig dig;            /*!< Current signature/pubkey parameters. */
  333.  
  334. /*@null@*/
  335.     Spec spec;            /*!< Spec file control structure. */
  336.  
  337. /*@kept@*/ /*@null@*/
  338.     rpmtsScore score;        /*!< Transaction Score (autorollback). */
  339.  
  340. /*@refs@*/
  341.     int nrefs;            /*!< Reference count. */
  342. };
  343. #endif    /* _RPMTS_INTERNAL */
  344.  
  345. #ifdef __cplusplus
  346. extern "C" {
  347. #endif
  348.  
  349. /** \ingroup rpmts
  350.  * Perform dependency resolution on the transaction set.
  351.  *
  352.  * Any problems found by rpmtsCheck() can be examined by retrieving the 
  353.  * problem set with rpmtsProblems(), success here only means that
  354.  * the resolution was successfully attempted for all packages in the set.
  355.  *
  356.  * @param ts        transaction set
  357.  * @return        0 on success
  358.  */
  359. int rpmtsCheck(rpmts ts)
  360.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  361.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  362.  
  363. /** \ingroup rpmts
  364.  * Determine package order in a transaction set according to dependencies.
  365.  *
  366.  * Order packages, returning error if circular dependencies cannot be
  367.  * eliminated by removing Requires's from the loop(s). Only dependencies from
  368.  * added or removed packages are used to determine ordering using a
  369.  * topological sort (Knuth vol. 1, p. 262). Use rpmtsCheck() to verify
  370.  * that all dependencies can be resolved.
  371.  *
  372.  * The final order ends up as installed packages followed by removed packages,
  373.  * with packages removed for upgrades immediately following the new package
  374.  * to be installed.
  375.  *
  376.  * @param ts        transaction set
  377.  * @return        no. of (added) packages that could not be ordered
  378.  */
  379. int rpmtsOrder(rpmts ts)
  380.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  381.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  382.  
  383. /** \ingroup rpmts
  384.  * Process all package elements in a transaction set.  Before calling
  385.  * rpmtsRun be sure to have:
  386.  *
  387.  *    - setup the rpm root dir via rpmtsSetRoot().
  388.  *    - setup the rpm notify callback via rpmtsSetNotifyCallback().
  389.  *    - setup the rpm transaction flags via rpmtsSetFlags().
  390.  * 
  391.  * Additionally, though not required you may want to:
  392.  *
  393.  *    - setup the rpm verify signature flags via rpmtsSetVSFlags().
  394.  *       
  395.  * @param ts        transaction set
  396.  * @param okProbs    previously known problems (or NULL)
  397.  * @param ignoreSet    bits to filter problem types
  398.  * @return        0 on success, -1 on error, >0 with newProbs set
  399.  */
  400. int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
  401.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  402.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  403.  
  404. /** \ingroup rpmts
  405.  * Unreference a transaction instance.
  406.  * @param ts        transaction set
  407.  * @param msg
  408.  * @return        NULL always
  409.  */
  410. /*@unused@*/ /*@null@*/
  411. rpmts rpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
  412.         const char * msg)
  413.     /*@modifies ts @*/;
  414.  
  415. /** @todo Remove debugging entry from the ABI. */
  416. /*@-exportlocal@*/
  417. /*@null@*/
  418. rpmts XrpmtsUnlink (/*@killref@*/ /*@only@*/ rpmts ts,
  419.         const char * msg, const char * fn, unsigned ln)
  420.     /*@modifies ts @*/;
  421. /*@=exportlocal@*/
  422. #define    rpmtsUnlink(_ts, _msg)    XrpmtsUnlink(_ts, _msg, __FILE__, __LINE__)
  423.  
  424. /** \ingroup rpmts
  425.  * Reference a transaction set instance.
  426.  * @param ts        transaction set
  427.  * @param msg
  428.  * @return        new transaction set reference
  429.  */
  430. /*@unused@*/
  431. rpmts rpmtsLink (rpmts ts, const char * msg)
  432.     /*@modifies ts @*/;
  433.  
  434. /** @todo Remove debugging entry from the ABI. */
  435. rpmts XrpmtsLink (rpmts ts,
  436.         const char * msg, const char * fn, unsigned ln)
  437.         /*@modifies ts @*/;
  438. #define    rpmtsLink(_ts, _msg)    XrpmtsLink(_ts, _msg, __FILE__, __LINE__)
  439.  
  440. /** \ingroup rpmts
  441.  * Close the database used by the transaction.
  442.  * @param ts        transaction set
  443.  * @return        0 on success
  444.  */
  445. int rpmtsCloseDB(rpmts ts)
  446.     /*@globals fileSystem @*/
  447.     /*@modifies ts, fileSystem @*/;
  448.  
  449. /** \ingroup rpmts
  450.  * Open the database used by the transaction.
  451.  * @param ts        transaction set
  452.  * @param dbmode    O_RDONLY or O_RDWR
  453.  * @return        0 on success
  454.  */
  455. int rpmtsOpenDB(rpmts ts, int dbmode)
  456.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  457.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  458.  
  459. /** \ingroup rpmts
  460.  * Initialize the database used by the transaction.
  461.  * @deprecated An explicit rpmdbInit() is almost never needed.
  462.  * @param ts        transaction set
  463.  * @param dbmode    O_RDONLY or O_RDWR
  464.  * @return        0 on success
  465.  */
  466. int rpmtsInitDB(rpmts ts, int dbmode)
  467.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  468.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  469.  
  470. /** \ingroup rpmts
  471.  * Rebuild the database used by the transaction.
  472.  * @param ts        transaction set
  473.  * @return        0 on success
  474.  */
  475. int rpmtsRebuildDB(rpmts ts)
  476.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  477.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  478.  
  479. /** \ingroup rpmts
  480.  * Verify the database used by the transaction.
  481.  * @param ts        transaction set
  482.  * @return        0 on success
  483.  */
  484. int rpmtsVerifyDB(rpmts ts)
  485.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  486.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  487.  
  488. /** \ingroup rpmts
  489.  * Return transaction database iterator.
  490.  * @param ts        transaction set
  491.  * @param rpmtag    rpm tag
  492.  * @param keyp        key data (NULL for sequential access)
  493.  * @param keylen    key data length (0 will use strlen(keyp))
  494.  * @return        NULL on failure
  495.  */
  496. /*@only@*/ /*@null@*/
  497. rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
  498.             /*@null@*/ const void * keyp, size_t keylen)
  499.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  500.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  501.  
  502. /**
  503.  * Retrieve pubkey from rpm database.
  504.  * @param ts        rpm transaction
  505.  * @return        RPMRC_OK on success, RPMRC_NOKEY if not found
  506.  */
  507. /*@-exportlocal@*/
  508. rpmRC rpmtsFindPubkey(rpmts ts)
  509.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  510.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState */;
  511. /*@=exportlocal@*/
  512.  
  513. /** \ingroup rpmts
  514.  * Close the database used by the transaction to solve dependencies.
  515.  * @param ts        transaction set
  516.  * @return        0 on success
  517.  */
  518. /*@-exportlocal@*/
  519. int rpmtsCloseSDB(rpmts ts)
  520.     /*@globals fileSystem @*/
  521.     /*@modifies ts, fileSystem @*/;
  522. /*@=exportlocal@*/
  523.  
  524. /** \ingroup rpmts
  525.  * Open the database used by the transaction to solve dependencies.
  526.  * @param ts        transaction set
  527.  * @param dbmode    O_RDONLY or O_RDWR
  528.  * @return        0 on success
  529.  */
  530. /*@-exportlocal@*/
  531. int rpmtsOpenSDB(rpmts ts, int dbmode)
  532.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  533.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  534. /*@=exportlocal@*/
  535.  
  536. /**
  537.  * Attempt to solve a needed dependency using the solve database.
  538.  * @param ts        transaction set
  539.  * @param ds        dependency set
  540.  * @param data        opaque data associated with callback
  541.  * @return        -1 retry, 0 ignore, 1 not found
  542.  */
  543. /*@-exportlocal@*/
  544. int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
  545.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  546.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  547. /*@=exportlocal@*/
  548.  
  549. /**
  550.  * Attempt to solve a needed dependency using memory resident tables.
  551.  * @deprecated This function will move from rpmlib to the python bindings.
  552.  * @param ts        transaction set
  553.  * @param ds        dependency set
  554.  * @return        0 if resolved (and added to ts), 1 not found
  555.  */
  556. /*@unused@*/
  557. int rpmtsAvailable(rpmts ts, const rpmds ds)
  558.     /*@globals fileSystem @*/
  559.     /*@modifies ts, fileSystem @*/;
  560.  
  561. /**
  562.  * Set dependency solver callback.
  563.  * @param ts        transaction set
  564.  * @param (*solve)    dependency solver callback
  565.  * @param solveData    dependency solver callback data (opaque)
  566.  * @return        0 on success
  567.  */
  568. int rpmtsSetSolveCallback(rpmts ts,
  569.         int (*solve) (rpmts ts, rpmds ds, const void * data),
  570.         const void * solveData)
  571.     /*@modifies ts @*/;
  572.  
  573. /**
  574.  * Return the type of a transaction.
  575.  * @param ts        transaction set
  576.  * @return        0 it is not, 1 it is.
  577.  */
  578. rpmtsType rpmtsGetType(rpmts ts)
  579.     /*@*/;
  580.  
  581. /**
  582.  * Set transaction type.   Allowed types are:
  583.  *
  584.  *     RPMTRANS_TYPE_NORMAL
  585.  *    RPMTRANS_TYPE_ROLLBACK
  586.  *     RPMTRANS_TYPE_AUTOROLLBACK
  587.  *
  588.  * @param ts        transaction set
  589.  * @param type        transaction type
  590.  * @return        void
  591.  */
  592. void rpmtsSetType(rpmts ts, rpmtsType type)
  593.     /*@modifies ts @*/;
  594.  
  595. /**
  596.  * Return current transaction set problems.
  597.  * @param ts        transaction set
  598.  * @return        current problem set (or NULL)
  599.  */
  600. /*@null@*/
  601. rpmps rpmtsProblems(rpmts ts)
  602.     /*@modifies ts @*/;
  603.  
  604. /** \ingroup rpmts
  605.  * Free signature verification data.
  606.  * @param ts        transaction set
  607.  */
  608. void rpmtsCleanDig(rpmts ts)
  609.     /*@modifies ts @*/;
  610.  
  611. /** \ingroup rpmts
  612.  * Free memory needed only for dependency checks and ordering.
  613.  * @param ts        transaction set
  614.  */
  615. void rpmtsClean(rpmts ts)
  616.     /*@globals fileSystem, internalState @*/
  617.     /*@modifies ts, fileSystem , internalState@*/;
  618.  
  619. /** \ingroup rpmts
  620.  * Re-create an empty transaction set.
  621.  * @param ts        transaction set
  622.  */
  623. void rpmtsEmpty(rpmts ts)
  624.     /*@globals fileSystem, internalState @*/
  625.     /*@modifies ts, fileSystem, internalState @*/;
  626.  
  627. /** \ingroup rpmts
  628.  * Destroy transaction set, closing the database as well.
  629.  * @param ts        transaction set
  630.  * @return        NULL always
  631.  */
  632. /*@null@*/
  633. rpmts rpmtsFree(/*@killref@*/ /*@only@*//*@null@*/ rpmts ts)
  634.     /*@globals fileSystem, internalState @*/
  635.     /*@modifies ts, fileSystem, internalState @*/;
  636.  
  637. /** \ingroup rpmts
  638.  * Get verify signatures flag(s).
  639.  * @param ts        transaction set
  640.  * @return        verify signatures flags
  641.  */
  642. rpmVSFlags rpmtsVSFlags(rpmts ts)
  643.     /*@*/;
  644.  
  645. /** \ingroup rpmts
  646.  * Set verify signatures flag(s).
  647.  * @param ts        transaction set
  648.  * @param vsflags    new verify signatures flags
  649.  * @return        previous value
  650.  */
  651. rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
  652.     /*@modifies ts @*/;
  653.  
  654. /** \ingroup rpmts
  655.  * Set index of 1st element of successors.
  656.  * @param ts        transaction set
  657.  * @param first        new index of 1st element of successors
  658.  * @return        previous value
  659.  */
  660. int rpmtsUnorderedSuccessors(rpmts ts, int first)
  661.     /*@modifies ts @*/;
  662.  
  663. /** \ingroup rpmts
  664.  * Get transaction rootDir, i.e. path to chroot(2).
  665.  * @param ts        transaction set
  666.  * @return        transaction rootDir
  667.  */
  668. /*@observer@*/ /*@null@*/
  669. extern const char * rpmtsRootDir(rpmts ts)
  670.     /*@*/;
  671.  
  672. /** \ingroup rpmts
  673.  * Set transaction rootDir, i.e. path to chroot(2).
  674.  * @param ts        transaction set
  675.  * @param rootDir    new transaction rootDir (or NULL)
  676.  */
  677. void rpmtsSetRootDir(rpmts ts, /*@null@*/ const char * rootDir)
  678.     /*@modifies ts @*/;
  679.  
  680. /** \ingroup rpmts
  681.  * Get transaction currDir, i.e. current directory before chroot(2).
  682.  * @param ts        transaction set
  683.  * @return        transaction currDir
  684.  */
  685. /*@observer@*/ /*@null@*/
  686. extern const char * rpmtsCurrDir(rpmts ts)
  687.     /*@*/;
  688.  
  689. /** \ingroup rpmts
  690.  * Set transaction currDir, i.e. current directory before chroot(2).
  691.  * @param ts        transaction set
  692.  * @param currDir    new transaction currDir (or NULL)
  693.  */
  694. void rpmtsSetCurrDir(rpmts ts, /*@null@*/ const char * currDir)
  695.     /*@modifies ts @*/;
  696.  
  697. /** \ingroup rpmts
  698.  * Get transaction script file handle, i.e. stdout/stderr on scriptlet execution
  699.  * @param ts        transaction set
  700.  * @return        transaction script file handle
  701.  */
  702. /*@null@*/
  703. FD_t rpmtsScriptFd(rpmts ts)
  704.     /*@*/;
  705.  
  706. /** \ingroup rpmts
  707.  * Set transaction script file handle, i.e. stdout/stderr on scriptlet execution
  708.  * @param ts        transaction set
  709.  * @param scriptFd    new script file handle (or NULL)
  710.  */
  711. void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd)
  712.     /*@modifies ts, scriptFd @*/;
  713.  
  714. /** \ingroup rpmts
  715.  * Get selinuxEnabled flag, i.e. is SE linux enabled?
  716.  * @param ts        transaction set
  717.  * @return        selinuxEnabled flag
  718.  */
  719. int rpmtsSELinuxEnabled(rpmts ts)
  720.     /*@*/;
  721.  
  722. /** \ingroup rpmts
  723.  * Get chrootDone flag, i.e. has chroot(2) been performed?
  724.  * @param ts        transaction set
  725.  * @return        chrootDone flag
  726.  */
  727. int rpmtsChrootDone(rpmts ts)
  728.     /*@*/;
  729.  
  730. /** \ingroup rpmts
  731.  * Set chrootDone flag, i.e. has chroot(2) been performed?
  732.  * @param ts        transaction set
  733.  * @param chrootDone    new chrootDone flag
  734.  * @return        previous chrootDone flag
  735.  */
  736. int rpmtsSetChrootDone(rpmts ts, int chrootDone)
  737.     /*@modifies ts @*/;
  738.  
  739. /** \ingroup rpmts
  740.  * Get file security context patterns.
  741.  * @param ts        transaction set
  742.  * @return        file security context patterns
  743.  */
  744. /*@null@*/
  745. rpmsx rpmtsREContext(const rpmts ts)
  746.     /*@modifies ts @*/;
  747.  
  748. /** \ingroup rpmts
  749.  * Get file security context patterns.
  750.  * @param ts        transaction set
  751.  * @param sx        security context patterns
  752.  * @return        0 on success
  753.  */
  754. int rpmtsSetREContext(rpmts ts, rpmsx sx)
  755.     /*@modifies ts, sx @*/;
  756.  
  757. /** \ingroup rpmts
  758.  * Get transaction id, i.e. transaction time stamp.
  759.  * @param ts        transaction set
  760.  * @return        transaction id
  761.  */
  762. int_32 rpmtsGetTid(rpmts ts)
  763.     /*@*/;
  764.  
  765. /** \ingroup rpmts
  766.  * Set transaction id, i.e. transaction time stamp.
  767.  * @param ts        transaction set
  768.  * @param tid        new transaction id
  769.  * @return        previous transaction id
  770.  */
  771. int_32 rpmtsSetTid(rpmts ts, int_32 tid)
  772.     /*@modifies ts @*/;
  773.  
  774. /** \ingroup rpmts
  775.  * Get signature tag.
  776.  * @param ts        transaction set
  777.  * @return        signature tag
  778.  */
  779. int_32 rpmtsSigtag(const rpmts ts)
  780.     /*@*/;
  781.  
  782. /** \ingroup rpmts
  783.  * Get signature tag type.
  784.  * @param ts        transaction set
  785.  * @return        signature tag type
  786.  */
  787. int_32 rpmtsSigtype(const rpmts ts)
  788.     /*@*/;
  789.  
  790. /** \ingroup rpmts
  791.  * Get signature tag data, i.e. from header.
  792.  * @param ts        transaction set
  793.  * @return        signature tag data
  794.  */
  795. /*@observer@*/ /*@null@*/
  796. extern const void * rpmtsSig(const rpmts ts)
  797.     /*@*/;
  798.  
  799. /** \ingroup rpmts
  800.  * Get signature tag data length, i.e. no. of bytes of data.
  801.  * @param ts        transaction set
  802.  * @return        signature tag data length
  803.  */
  804. int_32 rpmtsSiglen(const rpmts ts)
  805.     /*@*/;
  806.  
  807. /** \ingroup rpmts
  808.  * Set signature tag info, i.e. from header.
  809.  * @param ts        transaction set
  810.  * @param sigtag    signature tag
  811.  * @param sigtype    signature tag type
  812.  * @param sig        signature tag data
  813.  * @param siglen    signature tag data length
  814.  * @return        0 always
  815.  */
  816. int rpmtsSetSig(rpmts ts,
  817.         int_32 sigtag, int_32 sigtype,
  818.         /*@kept@*/ /*@null@*/ const void * sig, int_32 siglen)
  819.     /*@modifies ts @*/;
  820.  
  821. /** \ingroup rpmts
  822.  * Get OpenPGP packet parameters, i.e. signature/pubkey constants.
  823.  * @param ts        transaction set
  824.  * @return        signature/pubkey constants.
  825.  */
  826. /*@exposed@*/ /*@null@*/
  827. pgpDig rpmtsDig(rpmts ts)
  828.     /*@*/;
  829.  
  830. /** \ingroup rpmts
  831.  * Get OpenPGP signature constants.
  832.  * @param ts        transaction set
  833.  * @return        signature constants.
  834.  */
  835. /*@exposed@*/ /*@null@*/
  836. pgpDigParams rpmtsSignature(const rpmts ts)
  837.     /*@*/;
  838.  
  839. /** \ingroup rpmts
  840.  * Get OpenPGP pubkey constants.
  841.  * @param ts        transaction set
  842.  * @return        pubkey constants.
  843.  */
  844. /*@exposed@*/ /*@null@*/
  845. pgpDigParams rpmtsPubkey(const rpmts ts)
  846.     /*@*/;
  847.  
  848. /** \ingroup rpmts
  849.  * Get transaction set database handle.
  850.  * @param ts        transaction set
  851.  * @return        transaction database handle
  852.  */
  853. /*@null@*/
  854. rpmdb rpmtsGetRdb(rpmts ts)
  855.     /*@*/;
  856.  
  857. /** \ingroup rpmts
  858.  * Initialize disk space info for each and every mounted file systems.
  859.  * @param ts        transaction set
  860.  * @return        0 on success
  861.  */
  862. int rpmtsInitDSI(const rpmts ts)
  863.     /*@globals fileSystem, internalState @*/
  864.     /*@modifies ts, fileSystem, internalState @*/;
  865.  
  866. /** \ingroup rpmts
  867.  * Update disk space info for a file.
  868.  * @param ts        transaction set
  869.  * @param dev        mount point device
  870.  * @param fileSize    file size
  871.  * @param prevSize    previous file size (if upgrading)
  872.  * @param fixupSize    size difference (if
  873.  * @param action    file disposition
  874.  */
  875. void rpmtsUpdateDSI(const rpmts ts, dev_t dev,
  876.         uint_32 fileSize, uint_32 prevSize, uint_32 fixupSize,
  877.         fileAction action)
  878.     /*@modifies ts @*/;
  879.  
  880. /** \ingroup rpmts
  881.  * Check a transaction element for disk space problems.
  882.  * @param ts        transaction set
  883.  * @param te        current transaction element
  884.  */
  885. void rpmtsCheckDSIProblems(const rpmts ts, const rpmte te)
  886.     /*@modifies ts @*/;
  887.  
  888. /**
  889.  * Perform transaction progress notify callback.
  890.  * @param ts        transaction set
  891.  * @param te        current transaction element
  892.  * @param what        type of call back
  893.  * @param amount    current value
  894.  * @param total        final value
  895.  * @return        callback dependent pointer
  896.  */
  897. /*@null@*/
  898. void * rpmtsNotify(rpmts ts, rpmte te,
  899.                 rpmCallbackType what, unsigned long amount, unsigned long total)
  900.     /*@*/;
  901.  
  902. /**
  903.  * Return number of (ordered) transaction set elements.
  904.  * @param ts        transaction set
  905.  * @return        no. of transaction set elements
  906.  */
  907. int rpmtsNElements(rpmts ts)
  908.     /*@*/;
  909.  
  910. /**
  911.  * Return (ordered) transaction set element.
  912.  * @param ts        transaction set
  913.  * @param ix        transaction element index
  914.  * @return        transaction element (or NULL)
  915.  */
  916. /*@null@*/ /*@dependent@*/
  917. rpmte rpmtsElement(rpmts ts, int ix)
  918.     /*@*/;
  919.  
  920. /** \ingroup rpmts
  921.  * Get problem ignore bit mask, i.e. bits to filter encountered problems.
  922.  * @param ts        transaction set
  923.  * @return        ignore bit mask
  924.  */
  925. rpmprobFilterFlags rpmtsFilterFlags(rpmts ts)
  926.     /*@*/;
  927.  
  928. /** \ingroup rpmts
  929.  * Get transaction flags, i.e. bits that control rpmtsRun().
  930.  * @param ts        transaction set
  931.  * @return        transaction flags
  932.  */
  933. rpmtransFlags rpmtsFlags(rpmts ts)
  934.     /*@*/;
  935.  
  936. /** \ingroup rpmts
  937.  * Set transaction flags, i.e. bits that control rpmtsRun().
  938.  * @param ts        transaction set
  939.  * @param transFlags    new transaction flags
  940.  * @return        previous transaction flags
  941.  */
  942. rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
  943.     /*@modifies ts @*/;
  944.  
  945. /** \ingroup rpmts
  946.  * Get spec control structure from transaction set.
  947.  * @param ts        transaction set
  948.  * @return        spec control structure
  949.  */
  950. /*@null@*/
  951. Spec rpmtsSpec(rpmts ts)
  952.     /*@*/;
  953.  
  954. /** \ingroup rpmts
  955.  * Set a spec control structure in transaction set.
  956.  * @param ts        transaction set
  957.  * @param spec        new spec control structure
  958.  * @return        previous spec control structure
  959.  */
  960. /*@null@*/
  961. Spec rpmtsSetSpec(rpmts ts, /*@null@*/ Spec spec)
  962.     /*@modifies ts @*/;
  963.  
  964. /** \ingroup rpmts
  965.  * Get current relocate transaction element.
  966.  * @param ts        transaction set
  967.  * @return        current relocate transaction element
  968.  */
  969. /*@null@*/
  970. rpmte rpmtsRelocateElement(rpmts ts)
  971.     /*@*/;
  972.  
  973. /** \ingroup rpmts
  974.  * Set current relocate transaction element.
  975.  * @param ts        transaction set
  976.  * @param relocateElement new relocate transaction element
  977.  * @return        previous relocate transaction element
  978.  */
  979. /*@null@*/
  980. rpmte rpmtsSetRelocateElement(rpmts ts, /*@null@*/ rpmte relocateElement)
  981.     /*@modifies ts @*/;
  982.  
  983. /**
  984.  * Retrieve color bits of transaction set.
  985.  * @param ts        transaction set
  986.  * @return        color bits
  987.  */
  988. uint_32 rpmtsColor(rpmts ts)
  989.     /*@*/;
  990.  
  991. /**
  992.  * Retrieve prefered file color
  993.  * @param ts        transaction set
  994.  * @return        color bits
  995.  */
  996. uint_32 rpmtsPrefColor(rpmts ts)
  997.     /*@*/;
  998.  
  999. /**
  1000.  * Set color bits of transaction set.
  1001.  * @param ts        transaction set
  1002.  * @param color        new color bits
  1003.  * @return        previous color bits
  1004.  */
  1005. uint_32 rpmtsSetColor(rpmts ts, uint_32 color)
  1006.     /*@modifies ts @*/;
  1007.  
  1008. /**
  1009.  * Retrieve operation timestamp from a transaction set.
  1010.  * @param ts        transaction set
  1011.  * @param opx        operation timestamp index
  1012.  * @return        pointer to operation timestamp.
  1013.  */
  1014. /*@relnull@*/
  1015. rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
  1016.     /*@*/;
  1017.  
  1018. /** \ingroup rpmts
  1019.  * Set transaction notify callback function and argument.
  1020.  *
  1021.  * @warning This call must be made before rpmtsRun() for
  1022.  *    install/upgrade/freshen to function correctly.
  1023.  *
  1024.  * @param ts        transaction set
  1025.  * @param notify    progress callback
  1026.  * @param notifyData    progress callback private data
  1027.  * @return        0 on success
  1028.  */
  1029. int rpmtsSetNotifyCallback(rpmts ts,
  1030.         /*@observer@*/ rpmCallbackFunction notify,
  1031.         /*@observer@*/ rpmCallbackData notifyData)
  1032.     /*@modifies ts @*/;
  1033.  
  1034. /** \ingroup rpmts
  1035.  * Create an empty transaction set.
  1036.  * @return        new transaction set
  1037.  */
  1038. /*@newref@*/
  1039. rpmts rpmtsCreate(void)
  1040.     /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
  1041.     /*@modifies rpmGlobalMacroContext, internalState @*/;
  1042.  
  1043. /** \ingroup rpmts
  1044.  * Add package to be installed to transaction set.
  1045.  *
  1046.  * The transaction set is checked for duplicate package names.
  1047.  * If found, the package with the "newest" EVR will be replaced.
  1048.  *
  1049.  * @param ts        transaction set
  1050.  * @param h        header
  1051.  * @param key        package retrieval key (e.g. file name)
  1052.  * @param upgrade    is package being upgraded?
  1053.  * @param relocs    package file relocations
  1054.  * @return        0 on success, 1 on I/O error, 2 needs capabilities
  1055.  */
  1056. int rpmtsAddInstallElement(rpmts ts, Header h,
  1057.         /*@exposed@*/ /*@null@*/ const fnpyKey key, int upgrade,
  1058.         /*@null@*/ rpmRelocation * relocs)
  1059.     /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
  1060.         fileSystem, internalState @*/
  1061.     /*@modifies ts, h, rpmcliPackagesTotal, rpmGlobalMacroContext,
  1062.         fileSystem, internalState @*/;
  1063.  
  1064. /** \ingroup rpmts
  1065.  * Add package to be erased to transaction set.
  1066.  * @param ts        transaction set
  1067.  * @param h        header
  1068.  * @param dboffset    rpm database instance
  1069.  * @return        0 on success
  1070.  */
  1071. int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
  1072.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  1073.     /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
  1074.  
  1075. /** \ingroup rpmts
  1076.  * Retrieve keys from ordered transaction set.
  1077.  * @todo Removed packages have no keys, returned as interleaved NULL pointers.
  1078.  * @param ts        transaction set
  1079.  * @retval ep        address of returned element array pointer (or NULL)
  1080.  * @retval nep        address of no. of returned elements (or NULL)
  1081.  * @return        0 always
  1082.  */
  1083. /*@unused@*/
  1084. int rpmtsGetKeys(rpmts ts,
  1085.         /*@null@*/ /*@out@*/ fnpyKey ** ep,
  1086.         /*@null@*/ /*@out@*/ int * nep)
  1087.     /*@globals fileSystem, internalState @*/
  1088.     /*@modifies ts, ep, nep, fileSystem, internalState @*/;
  1089.  
  1090. /**
  1091.  * Return (malloc'd) header name-version-release string.
  1092.  * @param h        header
  1093.  * @retval np        name tag value
  1094.  * @return        name-version-release string
  1095.  */
  1096. /*@only@*/ char * hGetNEVR(Header h, /*@null@*/ /*@out@*/ const char ** np )
  1097.     /*@modifies *np @*/;
  1098.  
  1099. /**
  1100.  * Return (malloc'd) header name-version-release.arch string.
  1101.  * @param h        header
  1102.  * @retval np        name tag value
  1103.  * @return        name-version-release string
  1104.  */
  1105. /*@only@*/ char * hGetNEVRA(Header h, /*@null@*/ /*@out@*/ const char ** np )
  1106.     /*@modifies *np @*/;
  1107.  
  1108. /**
  1109.  * Return header color.
  1110.  * @param h        header
  1111.  * @return        header color
  1112.  */
  1113. uint_32 hGetColor(Header h)
  1114.     /*@modifies h @*/;
  1115.  
  1116. #ifdef __cplusplus
  1117. }
  1118. #endif
  1119.  
  1120.  
  1121. #endif    /* H_RPMTS */
  1122.